﻿using System.Collections.Generic;
using System.Linq;
using Journal.Common.Objects.Enums;

namespace Journal.Common.Models
{
    public class UrlModel
    {
        public UrlModel(IEnumerable<UrlModelItem> urlModelItems)
        {
            Urls = urlModelItems;
        }

        private IEnumerable<UrlModelItem> Urls { get; set; }

        public string GetUrl(UrlType urlType, object urlParameters)
        {
            if (Urls != null)
            {
                var urlItem = Urls.FirstOrDefault(x => x.UrlType == urlType);
                return urlItem != null ? urlItem.Url(urlParameters) : string.Empty;
            }

            return string.Empty;
        }
    }
}